<template>
	<view class="beijingse dingwei">
		<!-- 头部内容 -->
		<u-sticky>
			<view class="dingbu">
				<view class="" :style="{paddingTop:menutop+'rpx'}"></view>
			</view>
		</u-sticky>
		<!-- 头部 -->
		<view class="toububox dingwei">
			<image class="wodp" src="../static/image/system/wdx.png" mode=""></image>
			<view class="" style="z-index: 1;position: relative;">
				<view class="flexbetween"  @click="login" v-if="!is_login">
					<view class="flexleft">
						<image class="touxiang margin_right4" src="@/static/image/system/weidenglu.png" mode=""></image>
						<view class="bigtext xiaohei fonweight margin_right1">未登录，点击登录</view>
					</view>
					<u-icon name="arrow-right" color="#000000"></u-icon>
				</view>
				<view class="flexbetween" @click="jumper('/pages_mypage/gerenxx')" v-if="is_login">
					<view class="flexleft">
						<image class="touxiang margin_right4" :src="userInfo.avatar_text" mode=""></image>
						<view class="">
							<view class="bigtext xiaohei fonweight margin_right1">{{userInfo.nickname}}</view>
							<view class="xiaohui ershil margin_top1">{{userInfo.mobile}}</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#000000"></u-icon>
				</view>
				<view class="margin_top zhbox flexbetween" @click="jumper('/pages_mypage/yue?type=1')">
					<view class="titletext xiaohui">账户余额</view>
					<view class="titletext fonweight margin_top1" style="color: #FF7510;font-size: 40rpx;" v-if="userInfo">{{userInfo.money || 0}}</view>
					<view class="titletext fonweight margin_top1" style="color: #FF7510;font-size: 40rpx;" v-else>0</view>
					<!-- <view class="czbtn flexcenter" @click.stop="jumper('/pages_mypage/chongzhi')">
						<view class="strongtext xiaobai margin_right2">充值</view>
						<u-icon name="arrow-right" color="#FFFFFF"  size="12"></u-icon>
					</view> -->
				</view>
			</view>	
		</view>
		<view class="mainpadding2">
			<view class="ffffff radius mainpadding ">
				<view class="flexbetween"  @click="order1(0,0)">
					<view class="ershiba zhonghei">商品订单</view>
					<view class="flexright">
						<view class="strongtext xiaohui flexcenter margin_right2">查看全部订单</view>
						<u-icon name="arrow-right" color="#AFAFAF"></u-icon>
					</view>
				</view>
				<view class="margin_top5 flexbetween">
					<view class="ershiw flexcenter" @click="order1(1,1)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/dfk.png" mode=""></image>
								<u-badge class="jiaobiao" max="99" :value="wf_num"></u-badge>
							</view>
							<view class="strongtext zhonghei margin_top2">待付款</view>
						</view>
						
					</view>
					<!-- <view class="ershiw flexcenter" @click="order1(2)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/dfh.png" mode=""></image>
								<u-badge class="jiaobiao" max="99" :value="df_num"></u-badge>
							</view>
							<view class="strongtext zhonghei margin_top2">待发货</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(3)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/dsh.png" mode=""></image>
								<u-badge class="jiaobiao" max="99" :value="dsf_num"></u-badge>
							</view>
							<view class="strongtext zhonghei margin_top2">待收货</view>
						</view>
					</view> -->
					<!-- <view class="ershiw flexcenter" @click="order1(2,4)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/ywc.png" mode=""></image>
								<u-badge class="jiaobiao" max="99" :value="dpj_num"></u-badge>
							</view>
							<view class="strongtext zhonghei margin_top2">待评价</view>
						</view>
					</view> -->
					<view class="ershiw flexcenter" @click="order1(2,6)">
						<view class="">
							<view class="ddicon">
								<image src="../static/image/system/ywc.png" mode=""></image>
							</view>
							<view class="strongtext zhonghei margin_top2">已完成</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding2">
			<view class="mainpadding ffffff radius">
				<view class="flexbetween xiahuaxian margin-bottom"  v-if="is_login && userInfo.is_fy==2" @click="jumper('/pages_mypage/fuwudd')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<u-icon name="list-dot" color="#ff7510" size="20"></u-icon>
						</view>
						<view class="sanshier xiaohei">销售订单</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin-bottom" v-if="is_login && userInfo.is_fy==2" @click="jumper('/pages_mypage/yaoqinghy')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<u-icon name="share-square" color="#ff7510" size="20"></u-icon>
						</view>
						<view class="sanshier xiaohei">邀请好友</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin-bottom" v-if="userInfo.is_shop==2" @click="getsystem()">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<u-icon name="grid" color="#ff7510" size="20"></u-icon>
						</view>
						<view class="sanshier xiaohei">我的收款码</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin-bottom" v-if="userInfo.is_shop==2" @click="jumper('/pages_mypage/shoukuanls')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<u-icon name="list-dot" color="#ff7510" size="20"></u-icon>
						</view>
						<view class="sanshier xiaohei">支付订单</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
				<!-- <view class="flexbetween xiahuaxian margin_top" v-if="!isSH" @click="jumper('/pages_mypage/wodetd')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<u-icon name="list-dot" color="#ff7510" size="20"></u-icon>
						</view>
						<view class="sanshier xiaohei">我的团队</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view> -->
				<button open-type="contact" hover-class="none">
					<view class="flexbetween xiahuaxian margin-bottom">
						<view class="flexleft">
							<view class="myicon margin_right2">
								<u-icon name="kefu-ermai" color="#ff7510" size="20"></u-icon>
							</view>
							<view class="sanshier xiaohei">联系客服</view>
						</view>
						<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
					</view>
				</button>
				
				<view class="flexbetween" @click="jumper('/pages_mypage/shezhi')">
					<view class="flexleft">
						<view class="myicon margin_right2">
							<u-icon name="setting" color="#ff7510" size="20"></u-icon>
						</view>
						<view class="sanshier xiaohei">设置</view>
					</view>
					<u-icon name="arrow-right" color="#C8C8C8"></u-icon>
				</view>
			</view>
		</view>
		<u-popup :show="ewmshow" mode="center" @close="ewmshow = false" round="10">
			<view class="" style="padding-bottom: 50rpx;">
				<image src="@/static/image/system/ewmtop.png" mode="" class="ewmtop"></image>
				<view class="flexcenter">
					<!-- <image src="../../static/logo.png" class="ewm" mode=""></image> -->
					<uqrcode ref="uqrcode" canvas-id="qrcode" v-bind:value="qrcodeurl" :options="{ margin: 10}"
						size="150">
					</uqrcode>
				</view>
				<view class="xiaolv margin_top main_size flexcenter" style="font-weight: bold;">我的收款码</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				menutop: 80,
				is_login: false,
				userInfo: {},
				msgnum: {},
				show: false,
				title: '确定要退出当前账户么？',
				wf_num:0,
				df_num:0,
				dpj_num:0,
				dsf_num:0,
				isSH:false,
				ewmshow:false,
				qrcodeurl:"",
			}
		},
		onShareAppMessage: function(options) {
			return {
				title: '永星实业',
				imageUrl: '',
				path: '/pages/homepage'
			}
		},
		onShareTimeline: function() {
			return {
				title: '永星实业',
				imageUrl: '',
				path: '/pages/homepage'
			}
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.init()
				this.getnum()
			}else{
				this.userInfo = null
				this.wf_num=0
				this.df_num=0
				this.dpj_num=0
				this.dsf_num=0
			}
		},
		methods: {
			getsystem(){
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/index/getConfigInfoItem', 'POST', {
					pidtype:"about_set",
					type:"shoppay_url"
				}).then(res => {
					uni.hideLoading()
					this.qrcodeurl = res.data+"?shop_id="+uni.getStorageSync("user_id")
					this.ewmshow = true
				})
			},
			getnum(){
				httpRequest.request('/api/order/orderData', 'GET', {}).then(res => {
					if(res.code==1){
						this.wf_num=res.data.wf_num
						this.df_num=res.data.df_num
						this.dpj_num=res.data.dpj_num
						this.dsf_num=res.data.dsf_num
					}
				})
			},
			// 点击聊天
			contactkf(firend_id,type){
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/addFriends', 'GET', {
					firend_id,
					type
				}).then(res => {
					uni.hideLoading()
					let data = {
						firend_id:firend_id,
						friend_name: "宜品佳",
						firend_avatar_text: "@/static/image/logo.jpg"
					}
					if(res.code==1){
						uni.navigateTo({
							url:"/pages_mypage/chat?msg=" + encodeURIComponent(JSON.stringify(data))
						})
					}else{
						httpRequest.toast(res.msg)
					}
				})
			},
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					if(res.code==1){
						this.userInfo = res.data
						uni.setStorageSync("invite_code",res.data.invite_code)
					}else{
						this.userInfo = null
					}
				})
			},
			login() {
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
			// 跳转我的订单
			order1(i,val) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: '/pages_mypage/lipindd?i=' + i+"&tabsid="+val
				})
			},
			jumper(url) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.ewmtop {
		width: 500rpx;
		height: 180rpx;
	}
	.box{
			width: 100px; 
			height: 100px;
			background-color: #909193;
			border-radius: 15px;
		}
	.toububox{
		padding:0 30rpx 30rpx;
	}
	.czbtn{
		width: 146rpx;
		background-color: #FF7510;
		height:58rpx;
		border-radius: 56rpx;
	}
	.zhbox {
		background-color: #fdfcf8;
		padding: 24rpx 31rpx;
		border-radius: 14rpx;
	}

	.wodp {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 310rpx;
		z-index: 0;
	}

	.dingbu {
		padding: 12rpx 30rpx 30rpx;
		background-size: 100% 100%;
		width: 100%;
		box-sizing: border-box;
		background-image: url('@/static/image/system/wds.png');
	}

	.myicon {
		width: 38rpx;
		height: 38rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.hdbox {
		width: 48%;
		padding: 32rpx 25rpx 32rpx 34rpx;
		background-size: 100% 100%;
		box-sizing: border-box;
		background-image: url('https://solarmini.yuntaiqi.com/uploads/20240109/3dafd70f8df61618851184dbf3d1567e.png');
	}


	.jfbox {
		width: 48%;
		padding: 32rpx 25rpx 32rpx 34rpx;
		background-size: 100% 100%;
		box-sizing: border-box;
		background-image: url('https://solarmini.yuntaiqi.com/uploads/20240109/365317faefd2808ee177340534b8a25f.png');
	}

	.fuzhi {
		width: 28rpx;
		height: 28rpx;
	}

	.ddicon {
		width: 45rpx;
		height: 40.56rpx;
		margin: auto;
		position: relative;
		/deep/.u-badge{
			position: absolute;
			top:-30rpx;
			right: -30rpx;
		}
		image {
			margin: auto;
			width: 100%;
			height: 100%;
		}
	}

	.mbaibtn {
		width: 84rpx;
		height: 39rpx;
		background: rgba(255, 255, 255, 0.1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		border: 1rpx solid #FFFFFF;
	}

	.touxiang {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
	}
</style>